// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '平台' },
    redirect: '/account/settings',
    children: [
    // 数据填报
      {
        path: '/datafill',
        name: 'datafill',
        redirect: '/datafill/university',
        component: RouteView,
        meta: { title: '数据填报', keepAlive: true, icon: 'form', permission: ['DataFill'] },
        children: [
          {
            path: '/datafill/university',
            name: 'UniversityDataFill',
            component: () => import('@/views/datafill/university'),
            meta: { title: '"双一流"大学数据', keepAlive: false, permission: ['UniversityDataFill'] }
          },
          {
            path: '/datafill/subject-list',
            name: 'SubjectList',
            component: () => import('@/views/datafill/subjectList'),
            meta: { title: '"双一流"学科数据', keepAlive: false, permission: ['SubjectDataFill'] }
          }
        ]
      },
      // 数据管理
      {
        path: '/datamanage',
        name: 'datamanage',
        redirect: '/datamanage/university',
        component: RouteView,
        meta: { title: '数据管理', keepAlive: true, icon: 'copy', permission: ['DataManage'] },
        children: [
          {
            path: '/datamanage/university/:pageNo([1-9]\\d*)?',
            name: 'UniversityDataManage',
            component: () => import('@/views/datamanage/university'),
            meta: { title: '"双一流"大学数据', keepAlive: false }
          },
          {
            path: '/datamanage/subject-list',
            name: 'SubjectManageList',
            component: () => import('@/views/datamanage/subjectList'),
            meta: { title: '"双一流"学科数据', keepAlive: false }
          }
        ]
      },
      // 消息中心
      {
        path: '/message',
        name: 'message',
        redirect: '/message/index',
        component: RouteView,
        meta: { title: '消息中心', keepAlive: true, icon: 'mail' },
        children: [
          {
            path: '/message/index',
            name: 'Message',
            component: () => import('@/views/message/return'),
            meta: { title: '返回消息', keepAlive: false }
          }
        ]
      },
      // 用户管理
      {
        path: '/usermanage',
        name: 'usermanage',
        redirect: '/usermanage/check',
        component: RouteView,
        meta: { title: '用户管理', keepAlive: true, icon: 'user', permission: ['UserManage'] },
        children: [
          {
            path: '/usermanage/check',
            name: 'UserCheck',
            component: () => import('@/views//usermanage/check'),
            meta: { title: '用户列表', keepAlive: false }
          },
          {
            path: '/usermanage/add',
            name: 'UserAdd',
            component: () => import('@/views//usermanage/add'),
            meta: { title: '添加用户', keepAlive: false }
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  },
  {
    path: '/datafill',
    component: BasicLayout,
    meta: { title: '数据填报', keepAlive: true, icon: 'form' },
    children: [{
      path: '/datafill/subject/:pageNo([1-9]\\d*)?',
      name: 'SubjectDataFill',
      component: () => import('@/views/datafill/subject'),
      meta: { title: '双一流学科填写', keepAlive: false, permission: ['SubjectDataFill'] }
    }]
  },
  {
    path: '/datamanage',
    component: BasicLayout,
    meta: { title: '数据管理', keepAlive: true, icon: 'form' },
    children: [{
      path: '/datamanage/subject/:pageNo([1-9]\\d*)?',
      name: 'SubjectDataManage',
      component: () => import('@/views/datamanage/subject'),
      meta: { title: '双一流学科管理', keepAlive: false, permission: ['DataManage'] }
    }]
  },
  {
    path: '/account',
    component: BasicLayout,
    redirect: '/account/settings',
    name: 'account',
    meta: { title: '用户信息', icon: 'user', keepAlive: true },
    children: [
      {
        path: '/account/settings',
        name: 'settings',
        component: () => import('@/views/account/Setting'),
        meta: { title: '修改密码', hideHeader: true }
      }
    ]
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
